//类装饰器
/*
function fun1( target:any ){
    target.prototype.userName = '张三';
    target.age = 19;
}
@fun1
class Person1{
}
let p1 = new Person1();
//@ts-ignore
console.log( p1.userName );
//@ts-ignore
console.log( Person1.age );
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
//装饰器工厂
/*
function fun2( options:any ){
    return function( target:any ){
        target.prototype.userName = options.name;
        target.prototype.userAge = options.age;
    }
}
@fun2({
    name:'张三',
    age:18
})
class Person2{

}

let p2 = new Person2();
//@ts-ignore
console.log( p2.userName ,p2.userAge );
*/
//装饰器组合
/*
function demo1( target:any ){
    console.log('demo1');
}
function demo2(){
    console.log('demo2');
    return function(target:any){
        console.log('demo2 内部');
    }
}
function demo3(){
    console.log('demo3');
    return function(target:any){
        console.log('demo3 内部');
    }
}
function demo4( target:any ){
    console.log('demo4');
}

@demo1
@demo2()
@demo3()
@demo4
class Person3{

}
let p3 = new Person3();
*/
//属性装饰器
/*
function fun4( options:any ){
    return function(target:any , attr:any){
        target[attr] = options;
    }
}
class Person4{
    //@ts-ignore
    @fun4('李四')
    //@ts-ignore
    userName:string;
}

let p4 = new Person4();
console.log( p4.userName );
*/
function test(target, propertyKey, descriptor) {
    console.log(target);
    console.log(propertyKey);
}
var Person = /** @class */ (function () {
    function Person() {
    }
    Person.prototype.sayName = function () {
        console.log('say name...');
    };
    __decorate([
        test
    ], Person.prototype, "sayName");
    return Person;
}());
var p = new Person();
p.sayName();
